<div class="logo-wrapper">
  <a href="{{ "/" | relLangURL }}" class="logo">
    {{ if .Site.Params.logoTitle }}
      {{ .Site.Params.logoTitle | safeHTML }}
    {{ else }}
      {{ .Site.Title }}
    {{ end }}
  </a>
</div>

<nav class="site-navbar">
  <ul id="menu" class="menu">
    {{ $currentPage := . }}
    {{ range .Site.Menus.main }}
        <li class="menu-item{{if or ($currentPage.IsMenuCurrent "main" .) ($currentPage.HasMenuCurrent "main" .) }} active{{end}}">
        {{ if .HasChildren }}
          <!-- drop down navigation MENU -->
          <a class="menu-item-link menu-parent" href="{{ .URL | absLangURL | safeURL }}">{{ .Name }}</a>
          <ul class="submenu">
            {{ range .Children }}
              <li>
                <a href="{{ .URL | absLangURL | safeURL }}">{{ .Name }}</a>
              </li>
            {{ end }}
          </ul>

        {{ else }}
          <!-- normal MENU -->
          {{ if hasPrefix .URL "http" }}
            <a class="menu-item-link" href="{{ .URL | absLangURL | safeURL }}" rel="noopener" target="_blank">
              {{ .Name }}
              {{/* icon new window */}}
              <i class="iconfont">
                {{ partial "svg/new_window.svg" }}
              </i>
            </a>
          {{ else }}
            <a class="menu-item-link" href="{{ .URL | absLangURL | safeURL }}">{{ .Name }}</a>
          {{ end }}

        {{ end  }}

      </li>
    {{ end }}

    {{/* language chooser */}}
    {{ if and (gt (len .Site.Home.AllTranslations) 1) (.Site.Params.showMenuLanguageChooser | default false ) }}
      {{- $.Scratch.Set "language" .Language -}}
      <li class="menu-item">
        <!-- drop down navigation MENU -->
        <a class="menu-item-link menu-parent menu-item-lang" href="#">
          {{/* icon globe */}}
          <i class="iconfont">
            {{ partial "svg/globe.svg" }}
          </i>
          {{ .Site.Language.LanguageName }}
        </a>
        <ul class="submenu">
          {{ range .Site.Home.AllTranslations }}
            {{ if ne ($.Scratch.Get "language") .Language }}
              <li>
                <a href="{{ .Permalink }}">{{ .Language.LanguageName }}</a>
              </li>
            {{ end }}
          {{ end }}
        </ul>
      </li>
    {{ end }}

    {{ if .Site.Params.search.google.enable }}
      <li class="menu-item">
        <a id="openSearch" class="menu-item-link menu-item-search" href="#">
          <i class="iconfont">
            {{ partial "svg/search.svg" }}
          </i>
        </a>
      </li>
    {{ end }}
  </ul>
</nav>
